package com.franklin.java.configuration.sql.type;

import com.franklin.java.api.state.BaseProjectPersistentState;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;

/**
 * 选择的组，以项目为单位存储
 * @author Franklin
 * @since 2021/9/1 18:50
 */
@State(name = "com.franklin.java.configuration.sql.type.SelectGroupState",
    storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)})
public class SelectGroupState extends BaseProjectPersistentState<SelectGroupState> {
    public SelectGroupState(Project myProject) {
        super(myProject);
    }

    public SelectGroupState() {
    }

    public static final String DEFAULT_GROUP = "default";

    public String selectGroup = DEFAULT_GROUP;

    public static SelectGroupState getInstance(Project project){
        return project.getService(SelectGroupState.class);
    }

    public static String getSelectGroup(Project project){
        return getInstance(project).selectGroup;
    }
}
